/*
 * arg_parser.h
 *
 *  Created on: Aug 28, 2012
 *      Author: aortegag
 */

#ifndef ARG_PARSER_H_
#define ARG_PARSER_H_

/**
 * \brief Defines the maximum number of files we can open
 */
#define MAX_FILES	20

/**
 * \brief Simple list to process all the files given through command line.
 */
typedef	struct file {
	char * file_name;
	struct file *next;
}file_t;

/**
 * \brief Enumeration for the features our dissassembler provides.
 *
 * \note We want to start with 1 because the user will give from 1 to N
 * through the command line.
 */
typedef enum feature {
	FEATURE_1 = 1, 	//!< 0
	FEATURE_2,		//!< 1
	// Even though they are not named feature, they are indeed a feature.
	PRINT_ELF_HDR=30,
	PRINT_SECTION_HDR,
	PRINT_PROGRAM_HDR
}feature_t;

typedef struct dissassembler_arguments {
	int			   num_arguments;
	file_t *  	   files;
	unsigned short log_level;//!< Values go from 0 to 5.
	unsigned short verbose;  //!< Verbose output?
	feature_t 	   feature; //!< Which feature are we using?
	unsigned short display_features; //!< Do we display features?
}dissassembler_arguments;

/**
 * \brief Global variable made available to all the program.
 */
extern dissassembler_arguments	arguments;

/**
 * \brief Parses the arguments given on the command line
 *
 * \param[in] argc Number of arguments.
 * \param[in] argv Arguments vector.
 *
 * \retval 0 on success, otherwise error code.
 */
int parse_arguments(int argc, char *argv[]);

/**
 * \brief Adds a file to the list of files passed through command line.
 */
void	list_add_file(file_t *new_file);

/**
 * \brief Frees all the memory allocated while creating files for the
 * command line arguments.
 */
void 	list_free_files(file_t *first);

/**
 * \brief Prints all the files contained in the list.
 *
 * \warn This function should be called after the parsing of arguments
 * has finished.
 */
void 	list_print_files(file_t *first);

#endif /* ARG_PARSER_H_ */
